/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package tugasbesarjeni1.form.model;

import java.util.ArrayList;
import java.util.List;
import javax.swing.table.AbstractTableModel;
import tugasbesarjeni1.Database.VCD.Peminjaman;

/**
 *
 * @author Indy
 */
public class PeminjamanModel extends AbstractTableModel {
    private List<Peminjaman> list= new ArrayList<Peminjaman>();
    public void add(Peminjaman peminjaman){
        list.add(peminjaman);
        fireTableRowsInserted(getRowCount(), getColumnCount());
    }
    public Peminjaman get(int row){
        return (Peminjaman) list.get(row);
    }
    public void hapustable(int i, int row){
        list.remove(i);
        fireTableRowsDeleted(i, row);
    }

    public int getRowCount() {
        return list.size();
    }

    public int getColumnCount() {
        return 5;
    }

    public Object getValueAt(int rowIndex, int columnIndex) {
        switch(columnIndex){
            case 0: return list.get(rowIndex).getNo();
            case 1: return list.get(rowIndex).getKode();
            case 2: return list.get(rowIndex).getNama();
            case 3: return list.get(rowIndex).getJudul();
            case 4: return list.get(rowIndex).getHarga();
            default:return null;
        }
    }
    @Override
    public String getColumnName(int column){
        switch(column){
            case 0: return "NO";
            case 1: return "Kode";
            case 2: return "Nama";
            case 3: return "Judul";
            case 4: return "Harga Sewa";
            default:return null;
        }
    }


}
